#ifndef NETCLIENT_H
#define NETCLIENT_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QWebSocket>
#include <QProtobufSerializer>

#include "../model/data.h"

// 使用前置声明，防止头文件被循环引用
namespace model
{
class datacenter;
}

namespace network
{

class NetClient : public QObject
{
    Q_OBJECT
private:
    // 定义重要常量，ip和端口，ip目前使用本地回环地址，端口http：8080，websocket：8081
    const QString HTTP_URL = "http://127.0.0.1:8080";
    const QString WEBSOCKET_URL = "ws://127.0.0.1:8081/ws";

public:
    NetClient(model::datacenter* dc);
    ~NetClient();

public:
    // 验证网络通信
    void ping();

private:
    model::datacenter* dataCenter;

    // http客户端
    QNetworkAccessManager httpClient;

    // websocket 客户端
    QWebSocket webSocketClient;

    // 序列化器
    QProtobufSerializer serializer;

signals:
};

}   // end namespace


#endif // NETCLIENT_H
